package www.qiyue.sm;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import www.qiyue.utils.UUIDGenerator;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

@RestController
public class smRent {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @RequestMapping("smrent")
    public void test(){
        String sql = "SELECT * from ais_rentunit WHERE rent_unit_code = 'SC040-101'";
        Map<String, Object> map = jdbcTemplate.queryForMap(sql);
        String rent ="SELECT * from rent001";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(rent);
        for (Map<String, Object> objectMap : list) {
            Set<String> keySet = objectMap.keySet();
            for (String key : keySet) {
                map.put(key,objectMap.get(key));
            }
            map.put("id", UUIDGenerator.generate());
            map.put("remark", "test");
           String string ="INSERT INTO `sm`.`ais_rentunit`(`id`, `rent_unit_code`, `house_id`, `house_code`, `house_address`, `rent_address`, `part`, `room_type`, `usage_status`, `building_area`, `expansion_area`, `space_acreage`, `total_area`, `usage_type`, `use_company`, `user`, `network_admin`, `remark`, `company_id`, `affiliated_company_id`, `customer_code`, `customer_id`, `customer_name`, `situated_direction_id`, `district_id`, `ownership_id`, `section_name`, `usage_rights_id`, `ownership_nature_id`, `house_status_id`, `structure_id`, `massif`, `create_name`, `create_by`, `create_date`, `update_name`, `update_by`, `update_date`, `sys_org_code`, `sys_company_code`, `house_usage_id`, `section_id`, `network_admin_id`, `data_status_id`, `settlement_company_id`, `settlement_company`, `affiliated_company_full`, `affiliated_company_name`, `block_length_id`, `block_length`, `block_length_code`, `network_admin_account`, `sys_apportionarea`, `syncstatus`, `datastatus`, `finasysreason`, `syn_date`, `network_number`, `ncflag`, `involved_outlets`, `min_rent_price`, `bpm_time`, `price_status`, `bpm_end_time`, `bpm_end_time_old`, `min_rent_price_old`, `max_rent_price`, `price_remark`, `approval_remark`, `sys_org_code_s`, `update_name_old`, `update_date_old`, `information`) VALUES ('"+UUIDGenerator.generate()+"', '"+map.get("rent_unit_code")+"', '3845CD0809D74CDBA0236B0CF583B509', 'SC040', '市光一村115-116号', '市光一村115-116号101室', '一楼', NULL, '10', 661.02, 0.00, 0.00, 661.02, '08', 'D29C395BB9244E4DA8B8F1B624DDA156', NULL, '竺怡琼', NULL, '27DEF9F7494E43AAAE115CD69CEC5744', 'D29C395BB9244E4DA8B8F1B624DDA156', NULL, NULL, NULL, NULL, '09', '01', '市光路（中原路-白城路）', NULL, '01', '00', NULL, '00', '王子尧', '003289', '2021-06-01 00:00:00', NULL, NULL, NULL, 'A01A09', 'A0', '01', '2c83b3a9634ab9b20163b0438363181e', '2c83b3a979adb3250179c55cf80a0262', '01', NULL, NULL, '上海杨浦商业发展投资有限公司', '商投公司', '2c83b3a979adb3250179c55cf80a0262', '竺怡琼', '003296', '003092', NULL, '12', '00', NULL, NULL, NULL, 'Y', NULL, 0.0000, NULL, '00', NULL, NULL, NULL, 0.0000, NULL, NULL, NULL, NULL, NULL, '10')";
           jdbcTemplate.update(string);
        }

    }
}
